﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
    CodeFile="WorkGroup.aspx.cs" Inherits="WebForm_WorkGroup" %>

<script runat="server">
    /* list */
    protected void gv_DataBinding(object sender, EventArgs e)
    {
        var sql = new StringBuilder();
        var dbparams = new List<DBParameter>();

        sql.AppendFormat(string.Format(@"SELECT wg.* FROM WorkGroup wg WHERE CompID = @CompID "));

        dbparams.Add(new DBParameter("CompID", OrgManager.Current.CurrentComp));

        var db = new DB();
        var dt = db.Execute(sql.ToString(), dbparams.ToArray());

        (sender as DataBoundControl).DataSource = dt;

        mv.SetActiveView(vwList);
    }

    /* end of list */
</script>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="Server">
    <asp:MultiView ID="mv" runat="server" ActiveViewIndex="0">
        <asp:View ID="vwList" runat="server">
            <asp:LinkButton ID="btnAdd" runat="server" Text="<%$Resources: Form, btnAdd   %>"
                CommandName="MyInsert" OnClick="btnAdd_Click"></asp:LinkButton>
            <p />
            <My:MyGridView ID="gv" runat="server" OnDataBinding="gv_DataBinding" OnRowCommand="gv_ItemCommand"
                DataKeyNames="WorkGroupID">
                <Columns>
                    <asp:TemplateField HeaderText="<%$Resources: WorkGroup, WorkGroupID   %>">
                        <ItemTemplate>
                            <%# LocManager.Current.GetText("WorkGroup", "WorkGroupName", Eval("WorkGroupID")) %>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="<%$Resources: WorkGroup, WorkTime   %>">
                        <ItemTemplate>
                            <%# Eval("WorkStartTime") %>
                            ~
                            <%# Eval("WorkEndTime") %>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="<%$Resources: WorkBreak, WorkBreakTime   %>">
                        <ItemTemplate>
                            <asp:ListView ID="ListView1" runat="server" DataSource='<%# new DataView(BreakData, string.Format("WorkGroupID={0}",Eval("WorkGroupID")), "", DataViewRowState.CurrentRows) %>'>
                                <ItemTemplate>
                                <%# LocManager.Current.GetText("WorkBreak", "WorkBreakName", Eval("WorkGroupID"), Eval("WorkBreakID"))%> &nbsp;
                                    <%# Eval("WorkBreakStartTime") %>
                                    ~
                                    <%# Eval("WorkBreakEndTime") %>
                                </ItemTemplate>
                            </asp:ListView>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="<%$Resources: Holiday, HolidayGroupID   %>">
                        <ItemTemplate>
                            <%# LocManager.AttendanceCurrent.GetText("HolidayGroup", "HolidayGroupName", Eval("HolidayGroupID")) %>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField>
                        <ItemTemplate>
                        </ItemTemplate>
                    </asp:TemplateField>
                </Columns>
            </My:MyGridView>
        </asp:View>
    </asp:MultiView>
</asp:Content>
